package org.zhouhe.modules.hotinfo.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.zhouhe.base.BaseAction;
import org.zhouhe.modules.hotinfo.service.HotInfoService;
import org.zhouhe.page.PageUtil;
import org.zhouhe.vo.HotInfo;
import org.zhouhe.vo.HotInfoType;

public class HotInfoAction extends BaseAction {

	private static final long serialVersionUID = 896164905733014622L;
	private PageUtil pageUtil = new PageUtil();
	private HotInfo hotInfo = new HotInfo();
	private List<HotInfo> hotInfoList;
	private List<HotInfoType> hotInfoTypeList;
	@Autowired
	private HotInfoService hotInfoService;

	public String saveOrUpdate() {
		if (getHotInfo() != null && getHotInfo().getHotInfoId() != null) {
			setHotInfo(hotInfoService.getHotInfoDetail(getHotInfo()));
		} else {
			setHotInfo(new HotInfo());
		}
		if (this.pageUtil == null) {
			this.pageUtil = new PageUtil();
		}
		hotInfoTypeList = hotInfoService.getHotInfoTypeList();
		return "saveOrUpdate";
	}

	public String saveOrUpdateDo() {
		if (getHotInfo().getHotInfoId() == null) {// save
			hotInfoService.save(getHotInfo());
		} else {// update
			hotInfoService.update(getHotInfo());
		}
		return "saveOrUpdateDo";
	}

	public String delete() {
		hotInfoService.delete(getHotInfo());
		return "delete";
	}

	public String list() {
		hotInfoTypeList = hotInfoService.getHotInfoTypeList();
		pageUtil.setPageSize(1);
		hotInfoService.getHotInfoList(pageUtil, getHotInfo());
		return "list";
	}

	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}

	public PageUtil getPageUtil() {
		return pageUtil;
	}

	public void setHotInfoList(List<HotInfo> hotInfoList) {
		this.hotInfoList = hotInfoList;
	}

	public List<HotInfo> getHotInfoList() {
		return hotInfoList;
	}

	public void setHotInfo(HotInfo hotInfo) {
		this.hotInfo = hotInfo;
	}

	public HotInfo getHotInfo() {
		return hotInfo;
	}

	public void setHotInfoTypeList(List<HotInfoType> hotInfoTypeList) {
		this.hotInfoTypeList = hotInfoTypeList;
	}

	public List<HotInfoType> getHotInfoTypeList() {
		return hotInfoTypeList;
	}
}
